home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form UserForm1
- Caption = "Event Sample"
- ClientHeight = 510
- ClientLeft = 1740
- ClientTop = 1860
- ClientWidth = 5505
- Height = 915
- Left = 1680
- LinkTopic = "Form1"
- ScaleHeight = 510
- ScaleWidth = 5505
- Top = 1515
- Width = 5625
- Begin VB.TextBox TextBox1
- Height = 285
- Left = 1680
- TabIndex = 1
- Top = 120
- Width = 3615
- End
- Begin VB.Label Label1
- Caption = "Received Event ----->"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1575
- End
- Attribute VB_Name = "UserForm1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' -------------------------------------------------------------------------
- ' Copyright (C) 1996 Visio Corporation
- ' You have a royalty-free right to use, modify, reproduce and distribute
- ' the Sample Application Files (and/or any modified version) in any way
- ' you find useful, provided that you agree that Visio has no warranty,
- ' obligations or liability for any Sample Application Files.
- ' -------------------------------------------------------------------------
- Option Explicit
- Dim g_Sink As EventSink ' instance of class EventSink
- Dim g_Event As Visio.Event ' Event object
- Dim docObj As Visio.Document
- Private Sub Form_Load()
- ' Developing Visio Solutions, Chapter 15, Handling Events in Visio
- ' This example demonstrates:
- ' creating/retrieving a Visio instance
- ' creating an instance of a sink object
- ' adding a new drawing
- ' retrieving the eventlist for a document
- ' adding an event that runs an add-on
- ' adding an event that sends a notification
- Dim eventsObj As Visio.EventList
- ' Get the current instance of Visio if it is running or create a new one
- ' vaoGetObject is a helper utility found in visreg.bas
- If vaoGetObject() <> visOK Then
- MsgBox "Unable to load Visio!"
- End If
-
- ' Create an instance of the EventSink class
- ' g_Sink in global to the form.
- Set g_Sink = New EventSink
- ' Create a new drawing.
- Set docObj = g_appVisio.Documents.Add("")
- ' Get the EventList collection of this document.
- Set eventsObj = docObj.EventList
- ' Add an Event object that will run an add-on when the event fires.
- ' g_Event is global to this form
- Set g_Event = eventsObj.Add(visEvtShape + visEvtAdd, visActCodeRunAddon, _
- "ShowArgs.exe", "/args=Shape added!")
-
- ' Add event objects that will send notifications.
- ' Add an Event object for the DocumentSaved event.
- eventsObj.AddAdvise visEvtCodeDocSave, g_Sink, "", "Document Saved..."
- ' Add an Event object for the ShapeDeleted event.
- eventsObj.AddAdvise visEvtCodeShapeDelete, g_Sink, "", "Shape Deleted..."
- ' Add an Event object for the PageAdded event.
- eventsObj.AddAdvise (visEvtPage + visEvtAdd), g_Sink, "", "Page Added..."
- End Sub
-